﻿using J.Model;
using J.ProductGet.Application.Command.UploadPicturesCommand;
using MediatR;
using SqlSugar;

namespace J.ProductGet.Application.CommandHandler.UploadPicturesCommandHandler
{
    public class UploadPicturesBackCommandHandler : IRequestHandler<UploadPicturesBackCommand, List<UploadPictures>>
    {
        private readonly ISqlSugarClient _sqlSugarClient;
        public UploadPicturesBackCommandHandler(ISqlSugarClient sqlSugarClient)
        {
            _sqlSugarClient = sqlSugarClient;
        }
        public async Task<List<UploadPictures>> Handle(UploadPicturesBackCommand request, CancellationToken cancellationToken)
        {
            return await _sqlSugarClient.Queryable<UploadPictures>().Where(s => s.PictureId == request.PictureId).ToListAsync();
        }
    }
}
